#! /bin/bash
# while inotifywait -e close_write myfile.py; do ./myfile.py; done
src=workspace
inotifywait --monitor --recursive \
            --timefmt '%d/%m/%y %H:%M' \
            --format '%T %w %f' \
            --excludei 'doc' \
            -e close_write ${src} |
    while read -r date time dir file; do
        clear
        changed_abs=${dir}${file}
        echo "At ${time} on ${date}, file $changed_abs was changed" >&2
        cd ${src}
        smbclient --no-pass --user='\w14512%Wyq qwaszx!@' --ip-address='192.168.1.111' '\\Q13140Q\Users' \
                  --command '
cd \w14512\Downloads\hi\workspace;
prompt OFF;
recurse ON;
lcd ./workspace;
mput *'
        cd - # go back to the previous directory
        echo "Keep watching"
        sleep 5 # 🦜 : to avoid flooding the console with messages
    done

